<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jQuery Ajax</title>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
</head>
<body>
<div>
    请输入邮箱：<input type="text" id="email"/>
</div>
<div>
    请输入密码：<input type="password" id="password"/>
</div>
<div>
    请输入学号：<input type="text" id="studentNo"/>
</div>
<div>
    请输入姓名：<input type="text" id="name"/>
</div>
<div>
    请输入性别：<input type="text" id="gender"/>
</div>
<div>
    <button id="btn1">注册</button>
</div>


<div id="result">

</div>
</body>
<script type="text/javascript">
    $(document).ready(function () {
        $("#btn1").click(function () {
            let email = $("#email").val();
            let pwd = $("#password").val();
            let studentNo = $("#studentNo").val();
            let name = $("#name").val();
            let gender = $("#gender").val();

            let paramData = {
                "email": email,
                "passWord": pwd,
                "userInfo": {
                    "studentNo": studentNo,
                    "name": name,
                    "gender": gender
                }
            }

            $.ajax({
                type: 'post',
                url: "http://59.110.168.33:8082/register",
                // url: "http://localhost:8082/register",
                contentType: 'application/json;charset=utf-8',
                dataType: 'json',
                data: JSON.stringify(paramData),
                success: function (data) {
                    console.log(data);
                    if (data.status) {
                        $("#result").text("注册成功!");
                        window.location.href = "./order.html";
                    } else {
                        $("#result").text(data.msg)
                    }
                },
                error: function () {
                    $("#result").text("网络错误");
                }
            });
        });
    });
</script>
</html>